package com.pai4j.connect.controller;
import com.pai4j.common.bean.PAIResponseBean;
import com.pai4j.common.bean.PAIResponseBeanUtil;
import com.pai4j.common.util.JsonUtil;
import com.pai4j.connect.messagequeue.consumer.service.ChatMessageConsumeService;
import com.pai4j.domain.vo.request.mess.ChatMessageRequestVO;
import com.pai4j.remote.connect.ConnectServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConnectServiceController implements ConnectServiceClient {


    @Autowired
    private ChatMessageConsumeService chatMessageConsumeService;

    /**
     * 发送聊天消息处理方法
     *
     * @param messageRequestVO 聊天消息请求对象，包含消息内容、发送者、接收者等信息
     * @return PAIResponseBean<Boolean> 响应结果，成功时返回true
     */
    @Override
    public PAIResponseBean<Boolean> doSend(@RequestBody ChatMessageRequestVO messageRequestVO) {
        // 处理聊天消息，将消息请求对象转换为JSON字符串后进行消费处理
        chatMessageConsumeService.handleChatMessage(JsonUtil.toJsonString(messageRequestVO));
        return PAIResponseBeanUtil.success(true);
    }

}
